package com.feihong.txgw.ui.activity.Nearby.webviewinterface;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.webkit.JavascriptInterface;

import com.feihong.txgw.ui.activity.Nearby.MenDianDetailActivity;
import com.just.agentweb.AgentWeb;

/**
 * Created by PVer on 2017/8/10.
 */

public class MenDianDetailWebviewInterFace  {

    private AgentWeb agent;
    private Context context;
    private String address = "";
    private MenDianDetailActivity.ActionCallBack callBack;


    public MenDianDetailWebviewInterFace(AgentWeb agent, Context context,  MenDianDetailActivity.ActionCallBack callBack) {
        this.agent = agent;
        this.context = context;
        this.callBack = callBack;
    }


    private Handler deliver = new Handler(Looper.getMainLooper());

    //导航
    @JavascriptInterface
    public void navigate(final String json) {

        deliver.post(new Runnable() {
            @Override
            public void run() {
                if (callBack != null) {
                    callBack.navigate(json);
                }
            }
        });
    }

    //门店具体的位置
    @JavascriptInterface
    public void storeAddr(final String json) {

        deliver.post(new Runnable() {
            @Override
            public void run() {
                if (callBack != null) {
                    callBack.storeAddr(json);
                }
            }
        });
    }

    //店内详情
    @JavascriptInterface
    public void storeDetail(final String json) {

        deliver.post(new Runnable() {
            @Override
            public void run() {
                if (callBack != null) {
                    callBack.storeDetail(json);
                }
            }
        });
    }
}
